<?php

namespace app\admin\model\fas;

use think\Model;


class Zcdevice extends Model
{

    

    

    // 表名
    protected $table = 'fas_zcdevice';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'state_text'
    ];
    

    
    public function getStateList()
    {
        return ['0' => __('State 0'), '1' => __('State 1'), '2' => __('State 2'), '3' => __('State 3'), '4' => __('State 4'), '5' => __('State 5')];
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function zctype()
    {
        return $this->belongsTo('Zctype', 'zctype_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function zcorder()
    {
        return $this->belongsTo('Zcorder', 'zcorder_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
